package sk.mka.phd.googleagent.ngram;

import java.io.BufferedWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import org.apache.log4j.Logger;
import sk.mka.phd.files.reader.load.arbitrary.IArbitraryLoadDataFile;
import sk.mka.utils.tools.filesystem.FileUtils;

/**
 *
 * @author katrami
 * @date Dec 14, 2010
 */
public class AbstactAgent {

    private static final Logger log = Logger.getLogger(AbstractNgramAgent.class);
    protected IArbitraryLoadDataFile squareDataLoadFile;
    protected BufferedWriter bufferOutput;
    protected HashSet finalSet = new HashSet();

    protected void writeBufferToFile() {
        try {
            bufferOutput = FileUtils.openFileForWriting(squareDataLoadFile.getFinalPath(), Boolean.FALSE);
            for (Object object : finalSet) {
                ArrayList<Object> arrayList = (ArrayList<Object>) object;
                for (Object value : arrayList) {
                    bufferOutput.write(value.toString());
                    bufferOutput.write(" ");
                }
                bufferOutput.write("\n");
            }
            bufferOutput.close();
        } catch (IOException ex) {
            log.debug(ex);
        }

    }
}
